package com.xintonghua.bussiness.adapter;

import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.xintonghua.bussiness.R;
import com.xintonghua.bussiness.base.SimpleBaseAdapter;
import com.xintonghua.bussiness.bean.OkListBean;
import com.xintonghua.bussiness.bean.TaskManageResponse;
import com.xintonghua.bussiness.util.MyUtils;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 作者：wanxianyi
 * 时间：2018/4/1.
 * 包名：com.xintonghua.bussiness.adapter
 */

public class TaskManageAdapter extends SimpleBaseAdapter<OkListBean> {

    public TaskManageAdapter(List<OkListBean> list, Context context) {
        super(list, context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        TaskManageViewHolder holder;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.adapter_task_manage, null);
            holder = new TaskManageViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (TaskManageViewHolder) convertView.getTag();

        }
        OkListBean bean = mList.get(position);
        holder.tvTime.setText(bean.getTime());
        holder.tvPrice.setText(MyUtils.getMoney(context, bean.getMoney()));
        holder.tvProcess.setText(bean.getPercent());
        holder.tvPrice.setTextColor(ContextCompat.getColor(context,bean.getOktask()>0?R.color.red:R.color.green));
        holder.tvProcess.setTextColor(ContextCompat.getColor(context,bean.getOktask()>0?R.color.red:R.color.green));

        return convertView;
    }

    static class TaskManageViewHolder {
        @BindView(R.id.tv_time)
        TextView tvTime;
        @BindView(R.id.tv_price)
        TextView tvPrice;
        @BindView(R.id.tv_process)
        TextView tvProcess;

        public TaskManageViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
